package com.kaifamiao.tags;

import javax.servlet.jsp.JspContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;

public class HelloTag extends SimpleTagSupport {

    public HelloTag() {
        System.out.println( "创建HelloTag实例" );
    }

    @Override
    public void doTag() throws JspException, IOException {
        // 获得JSP上下文对象(相当于JSP中的pageContext对象)
        JspContext jc = this.getJspContext();
        // 获得 JSP 内置对象 out
        JspWriter out = jc.getOut();

        out.println( "<div style='color:green;text-align:center;font-weight:bold;border:1px solid blue;'>" );
        out.println( "hello" );
        out.println( "</div>");
    }

}
